#include "InfoState.h"
#include "Game.h"
#include "TestState.h"
#include "ScreenManager.h"
#include "DX11HelpfulDrawFunctions.h"
#include "DX11TextureManager.h"

InfoState::InfoState()
{
	m_screenSize.x = (float)TheScreenManager::Instance()->GetWindowWidth();
	m_screenSize.y = (float)TheScreenManager::Instance()->GetWindowHeight();
}

void InfoState::Draw()
{
	DX11::ClearColour(0.0f, 0.0f, 0.0f, 1.0f);
	
	TheTestState::Instance()->DrawOptionsView();

	D3DXMATRIX m_view;
	D3DXMATRIX m_proj;

	D3DXMatrixLookAtLH(&m_view, &D3DXVECTOR3(0.0f, 0.0f, 1.0f), 
		&D3DXVECTOR3(0.0f, 0.0f, 0.0f), 
		&D3DXVECTOR3(0.0f, 1.0f, 0.0f));
	
	D3DXMatrixOrthoLH(&m_proj, m_screenSize.x, m_screenSize.y, 0, 100);

	TheScreenManager::Instance()->SetViewProjMatrix(m_view, m_proj);
			
	TheScreenManager::Instance()->EnableBlending();
	TheObjMeshManager::Instance()->ChangeTexture("title_quad",
		TheDX11TextureManager::Instance()->UseTexture(L"../../Assets/tutorial_image.png"));
	//TheObjMeshManager::Instance()->Translate("title_quad", D3DXVECTOR3(0.0f, -1.0f, rot));
	TheObjMeshManager::Instance()->Scale("title_quad", D3DXVECTOR3(m_screenSize.x, m_screenSize.y, 1.0f));
	//TheObjMeshManager::Instance()->Rotate("title_quad", M_PI_4, 1.0f, 0.0f, 0.0f);
	TheObjMeshManager::Instance()->Draw("title_quad");
	TheScreenManager::Instance()->DisableBlending();
}

void InfoState::Update()
{

}

void InfoState::OnActivated()
{
	TheEventPoller::Instance()->AddHandler(this);
}

void InfoState::OnDeactivated()
{
	TheEventPoller::Instance()->RemoveHandler(this);
}

void InfoState::OnKeyDownEvent(const WPARAM& event)
{
	if (event == VK_RETURN)
	{
		TheGame::Instance()->SetGameState(TheTestState::Instance());
	}
}